
package com.dps.omc.service.impl;
import com.dps.common.domain.view.BizData4Page;
import com.dps.omc.dao.ITemplateShellDAO;
import com.dps.omc.model.TemplateShell;
import com.dps.omc.service.ITemplateShellService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.dps.common.service.impl.AbstractPageService;

import java.util.List;
import java.util.Map;

@SuppressWarnings("unchecked")
@Service("TemplateShellServiceImpl")

public class TemplateShellServiceImpl extends AbstractPageService<ITemplateShellDAO,TemplateShell> implements ITemplateShellService {

	@Autowired
	private ITemplateShellDAO templateShellDAO;
	@Override
	public boolean getEnableDataPerm() {
		// TODO Auto-generated method stub
		return false;
	}
	@Override
	public ITemplateShellDAO getDao() {
		return templateShellDAO;
	}

	@Override
	public BizData4Page queryPageByTypeNodeId(Map<String, Object> conditions, int curPage, int offset, int rows) {
		List<TemplateShell> mainData = templateShellDAO.queryPage(conditions, offset, rows);
		int records =  getDao().count(conditions);
		BizData4Page bizData4Page = new BizData4Page();
		bizData4Page.setRows(mainData);
		bizData4Page.setPage(curPage);
		bizData4Page.setRecords(records);

		int total = records / rows;
		int mod = records % rows;
		if(mod > 0){
			total = total + 1;
		}
		bizData4Page.setTotal(total);

		return bizData4Page;
	}
}
